package com.example.work;

import android.content.Intent;
import android.graphics.Typeface;
import android.os.Bundle;
import android.widget.TextView;

import androidx.activity.EdgeToEdge;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.graphics.Insets;
import androidx.core.view.ViewCompat;
import androidx.core.view.WindowInsetsCompat;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {


    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        EdgeToEdge.enable(this);
        setContentView(R.layout.activity_main);
        ViewCompat.setOnApplyWindowInsetsListener(findViewById(R.id.main), (v, insets) -> {
            Insets systemBars = insets.getInsets(WindowInsetsCompat.Type.systemBars());
            v.setPadding(systemBars.left, systemBars.top, systemBars.right, systemBars.bottom);
            return insets;
        });

        ((TextView) findViewById(R.id.order)).setOnClickListener(v -> {
            ((TextView) findViewById(R.id.order)).setTextColor(getResources().getColor(R.color.black));
            ((TextView) findViewById(R.id.order)).setTextSize(20);
            ((TextView) findViewById(R.id.assess)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.assess)).setTextSize(12);
            ((TextView) findViewById(R.id.merchants)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.merchants)).setTextSize(12);
        });
        ((TextView) findViewById(R.id.assess)).setOnClickListener(v -> {
            ((TextView) findViewById(R.id.assess)).setTextColor(getResources().getColor(R.color.black));
            ((TextView) findViewById(R.id.assess)).setTextSize(20);
            ((TextView) findViewById(R.id.order)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.order)).setTextSize(12);
            ((TextView) findViewById(R.id.merchants)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.merchants)).setTextSize(12);
        });
        ((TextView) findViewById(R.id.merchants)).setOnClickListener(v -> {
            ((TextView) findViewById(R.id.merchants)).setTextColor(getResources().getColor(R.color.black));
            ((TextView) findViewById(R.id.merchants)).setTextSize(20);
            ((TextView) findViewById(R.id.order)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.order)).setTextSize(12);
            ((TextView) findViewById(R.id.assess)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.assess)).setTextSize(12);
        });

        // 获取R.id.list 的ListView控件
        ((TextView) findViewById(R.id.groom)).setOnClickListener(v ->{
            ((TextView) findViewById(R.id.groom)).setBackgroundColor(getResources().getColor(R.color.white));
            ((TextView) findViewById(R.id.groom)).setTextColor(getResources().getColor(R.color.black));
            ((TextView) findViewById(R.id.groom)).setTextSize(20);

            ((TextView) findViewById(R.id.must_buy)).setBackgroundColor(getResources().getColor(R.color.text_bg_color));
            ((TextView) findViewById(R.id.must_buy)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.must_buy)).setTextSize(12);
            // 找fragment
            Intent intent = new Intent(MainActivity.this, BlankFragment.class);
            Bundle bundle = new Bundle();
            bundle.putInt("type",0);
            intent.putExtras(bundle);
            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_tag_view,new BlankFragment()).commit();
        });

        ((TextView) findViewById(R.id.must_buy)).setOnClickListener(v ->{
            ((TextView) findViewById(R.id.must_buy)).setBackgroundColor(getResources().getColor(R.color.white));
            ((TextView) findViewById(R.id.must_buy)).setTextColor(getResources().getColor(R.color.black));
            ((TextView) findViewById(R.id.must_buy)).setTextSize(20);
            ((TextView) findViewById(R.id.groom)).setBackgroundColor(getResources().getColor(R.color.text_bg_color));
            ((TextView) findViewById(R.id.groom)).setTextColor(getResources().getColor(R.color.text_hui));
            ((TextView) findViewById(R.id.groom)).setTextSize(12);
            // 传递 1
            Intent intent = new Intent(MainActivity.this, BlankFragment.class);
            Bundle bundle = new Bundle();
            bundle.putInt("type",1);
            intent.putExtras(bundle);
            getSupportFragmentManager().beginTransaction().replace(R.id.fragment_tag_view,new BlankFragment()).commit();
        });
    }
}